import 'package:flutter/material.dart';
import 'package:zhrs/Model/message.dart';
import 'package:zhrs/mainpage/Intelligentcustomer.dart';
import 'package:zhrs/mainpage/service.dart';
import 'package:zhrs/mainpage/newinformation.dart';
import 'package:zhrs/Utils/windowsSize.dart';
import 'package:zhrs/mainpage/recommendation.dart';
import 'package:zhrs/utils/StaticContent.dart';

class MainBody extends StatefulWidget
{
  Function reset;
  BuildContext context;
  var  pageState;

  MainBody({this.index=1,this.reset,this.context,this.pageState})
  {


    if(index==1)
      {
        this.imgUrl='http://106.12.180.103/smartDemo/images/head-male.png';
        this.name="张明清";
        this.topinformationss=topinformationsman;
        this.newinformations=newinformationsman;
        this.applicationfunctionss=applicationfunctionssman;
        this.recommendationmessagess=recommendationmessagesman;
      }

    if(index==2)
      {
        this.imgUrl='http://106.12.180.103/smartDemo/images/head-female.png';
        this.name="李敏惠";
        this.topinformationss=topinformationswoman;
        this.newinformations=newinformationswoman;
        this.applicationfunctionss=applicationfunctionsswoman;
        this.recommendationmessagess=recommendationmessageswoman;
      }
    if(index==3)
    {
      this.imgUrl='http://106.12.180.103/smartDemo/images/head-aged.png';
      this.name="高玉怀";
      this.topinformationss=topinformationsold;
      this.newinformations=newinformationsold;
      this.applicationfunctionss=applicationfunctionssold;
      this.recommendationmessagess=recommendationmessagesold;
    }
  }
  int index;
  String imgUrl;
  String name;
  List<topinformation> topinformationss;
  List<newsinformation> newinformations;
  List<applicationfunctions> applicationfunctionss;
  List<recommendationmessage> recommendationmessagess;


  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _MainBody();
  }
}
class _MainBody extends State<MainBody> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  void navaicateTopage(String url)
  {
   // widget.reset(url:"http://106.12.180.103/flutter02.html");
    //Webviewpage.controller.loadUrl("http://106.12.180.103/flutter02.html");
    //Webviewpage.controller.evaluateJavascript('writeRegistrationID("22222222222)');
    Navigator.push(context, new MaterialPageRoute(
    builder :(context)=>new Intelligentcustomer(),
    )).then((val){

      StaticContent.pageState=widget.pageState;
      StaticContent.contexts=widget.context;
    });
  //print(alertDialog(context, url));
  }
  @override
  Widget build(BuildContext context) {
    print("宽度是：" + MediaQuery
        .of(context)
        .size
        .width
        .toString());
    windowsSize.mapViewWidth = MediaQuery
        .of(context)
        .size
        .width;
    windowsSize.mapViewHeight = MediaQuery
        .of(context)
        .size
        .height;
    // TODO: implement build
    return new Container(
      // MediaQuery.removePadding(context: null, child: null),
      child:  MediaQuery.removePadding(
            removeTop: true,
            context: context,
            child: Container(
              height:windowsSize.mapViewHeight ,
              child: ListView(

                children: <Widget>[
                  Column(
                    children: <Widget>[

                      Container(
                        color: Colors.lightBlue,
                        height: windowsSize.mapViewHeight * 0.08,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: <Widget>[
                            Container(

                              child: Icon(Icons.format_list_bulleted,
                                size: windowsSize.mapViewWidth * 0.08,
                                color: Colors.white,),
                            ),
                            Container(
                              child:    Container(
                                width: windowsSize.mapViewWidth * 0.7,
                                height: windowsSize.mapViewHeight * 0.04,
                                child: Padding(
                                  padding: const EdgeInsets.fromLTRB(
                                      0, 0, 0, 0),
                                  child: TextField(
                                    style: TextStyle(
                                      fontSize: 15, color: Colors.black,),
                                    decoration: InputDecoration(
                                        contentPadding: EdgeInsets.all(5.0),
                                        prefixIcon: Icon(Icons.search),
                                        border: OutlineInputBorder(
                                          borderRadius: BorderRadius
                                              .circular(60),
                                          borderSide: BorderSide.none
                                        ),
                                        filled: true,
                                        hintText: "要查询的关键字",
                                        fillColor: Colors.white30,

                                    ),
                                  ),
                                ),
                              ),
                            ),
                            Container(
                           
                              child: Icon(Icons.crop_free,
                                size: windowsSize.mapViewWidth * 0.08,
                                color: Colors.white,),
                            ),
                          ],
                        ),
                      ),
                      Container(
                        height: windowsSize.mapViewHeight -windowsSize.mapViewHeight * 0.18 ,
                        child:ListView(

                          children: <Widget>[
                            Stack(
                              children: <Widget>[
                                Column(

                                  children: <Widget>[
                                    Stack(
                                      children: <Widget>[
                                        Container(
                                          height: windowsSize.mapViewHeight * 0.3,
                                          color: Colors.lightBlue,
                                          child: Column(
                                            children: <Widget>[


                                              Container(
                                                height: windowsSize.mapViewHeight * 0.22,

                                                child: Row(
                                                  children: <Widget>[
                                                    Container(
                                                      height: windowsSize.mapViewWidth * 0.35,
                                                      width: windowsSize.mapViewWidth * 0.35,
                                                      // color: Colors.redAccent,
                                                      padding: EdgeInsets.only(top: 0),
                                                      child: Column(
                                                        children: <Widget>[
                                                          Container(
                                                            decoration: BoxDecoration(border: Border.all(width:4, color: Colors.white30),
                                                                shape: BoxShape.rectangle,
                                                                borderRadius:
                                                                const BorderRadius.all(const Radius.circular(360.0))),
                                                            child: new ClipRRect(
                                                              borderRadius: const BorderRadius.all(const Radius.circular(360.0)),
                                                              child:Container(

                                                                height: windowsSize.mapViewWidth *
                                                                    0.22,
                                                                width: windowsSize.mapViewWidth *
                                                                    0.22,
                                                                child:  new Image.network(//加载网络图片
                                                                  widget.imgUrl,
                                                                  height: windowsSize.mapViewWidth *
                                                                      0.23,
                                                                  width: windowsSize.mapViewWidth *
                                                                      0.23,
                                                                  repeat: ImageRepeat.noRepeat,//图片重复方式
                                                                  // fit: BoxFit.fill,
                                                                ),
                                                              ),
                                                            ),
                                                          ),

                                                          Container(
                                                            //color: Colors.grey,
                                                            padding: EdgeInsets.only(top: 3),
                                                            child: Container(
                                                              width: windowsSize.mapViewWidth *
                                                                  0.17,
                                                              color: Colors.white30,
                                                              padding: EdgeInsets.only(
                                                                  top: 1.5),
                                                              child: Text(widget.name,
                                                                textAlign: TextAlign.center,
                                                                style: TextStyle(
                                                                    fontSize: windowsSize
                                                                        .mapViewWidth * 0.05,
                                                                    color: Colors.white),),
                                                            ),
                                                          ),
                                                        ],
                                                      ),
                                                    ),
                                                    Container(
                                                   
                                                      height: windowsSize.mapViewWidth * 0.35,
                                                      width: windowsSize.mapViewWidth * 0.65,
                                                      child: Column(
                                                        children: <Widget>[
                                                          Column(
                                                            children: widget.topinformationss.map((topinformation)
                                                            {
                                                              return    Padding(
                                                                  padding: EdgeInsets.only(
                                                                      bottom: 5,
                                                                      left: 0),
                                                                  child: Row(
                                                                    children: <Widget>[
                                                                      Icon(Icons.message,
                                                                        size: windowsSize
                                                                            .mapViewWidth * 0.06,
                                                                        color: topinformation.color,),
                                                                      Container(
                                                                        child: Text(
                                                                          topinformation.description,
                                                                          style: TextStyle(
                                                                            fontSize: windowsSize
                                                                                .mapViewWidth *
                                                                                0.035,
                                                                            color: Colors.white,),),
                                                                      )
                                                                    ],
                                                                  ));

                                                            }).toList(),

                                                          ),
                                                          Column(
                                                            children: <Widget>[
                                                              Padding(padding: EdgeInsets.only(
                                                                  left: 0, top: 5),
                                                                  child: Row(
                                                                    children: <Widget>[
                                                                      Icon(Icons.contact_phone,
                                                                        size: windowsSize
                                                                            .mapViewWidth * 0.07,
                                                                        color: Colors.white,),
                                                                      Container(
                                                                        padding: EdgeInsets.only(
                                                                            left: 10, right: 10),
                                                                        child: Text("已实名认证",
                                                                          style: TextStyle(
                                                                            fontSize: windowsSize
                                                                                .mapViewWidth *
                                                                                0.035,
                                                                            color: Colors.white,),),
                                                                      ),
                                                                      Icon(Icons.phone_iphone,
                                                                        size: windowsSize
                                                                            .mapViewWidth * 0.07,
                                                                        color: Colors.white,),
                                                                      Container(
                                                                        padding: EdgeInsets.only(
                                                                            left: 10),
                                                                        child: Text("已实名认证",
                                                                          style: TextStyle(
                                                                            fontSize: windowsSize
                                                                                .mapViewWidth *
                                                                                0.035,
                                                                            color: Colors.white,),),
                                                                      ),
                                                                    ],
                                                                  )),
                                                            ],
                                                          ),
                                                        ],
                                                      ),
                                                    )
                                                  ],
                                                ),
                                              )
                                            ],
                                          ),
                                        ),
                                        new Opacity(
                                          opacity: 0.6,
                                          child: new Container(

                                            padding: EdgeInsets.only(top: windowsSize.mapViewHeight * 0.03,
                                                left: windowsSize.mapViewWidth*0.55, right: 0),
                                            child: new Image.network( //加载网络图片
                                              'http://106.12.180.103/smartDemo/images/bg-n.png',
                                              height: windowsSize.mapViewHeight * 0.42- windowsSize.mapViewHeight * 0.07,
                                              width: windowsSize.mapViewWidth*0.5,
                                              repeat: ImageRepeat.noRepeat, //图片重复方式
                                              // fit: BoxFit.fill,
                                            ),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                                Padding(
                                  padding: EdgeInsets.only(
                                      top: windowsSize.mapViewHeight * 0.24),
                                  child: Container(
                                    //color: Colors.white,
                                    // padding: EdgeInsets.only(top: windowsSize. mapViewHeight*0.35),
                                      child: Column(
                                        children: <Widget>[
                                          Center(
                                            child: Container(
                                                width: windowsSize.mapViewWidth * 0.96,
                                                decoration: BoxDecoration(
                                                    border: Border.all(
                                                        width: 1, color: Colors.black12),
                                                    shape: BoxShape.rectangle,
                                                    borderRadius:
                                                    const BorderRadius.all(
                                                        const Radius.circular(20.0))),
                                                //width: windowsSize.mapViewWidth * 0.95,
                                                // height:windowsSize. mapViewWidth*0.75,
                                                child: new ClipRRect(
                                                  borderRadius: const BorderRadius.all(
                                                      const Radius.circular(18.0)),
                                                  child: Column(
                                                    children: <Widget>[
                                                      Container(
                                                        width: windowsSize.mapViewWidth * 0.96,
                                                        // height:  windowsSize. mapViewHeight*0.07,
                                                        padding: EdgeInsets.only(
                                                            top: 15, left: 15, bottom: 15),
                                                        color: Colors.white,
                                                        child: new Text(
                                                            '我的应用',
                                                            style: new TextStyle(
                                                              color: Colors.orange,
                                                              fontSize: 18.0,)),
                                                      ),
                                                      Container(
                                                        color: Colors.white,
                                                        child: Container
                                                          (
                                                          width: windowsSize.mapViewWidth *
                                                              0.90,
                                                          color: Colors.black12,
                                                          height: 1,
                                                        ),
                                                      ),
                                                      Container(
                                                        padding: EdgeInsets.only(top: 15),
                                                        color: Colors.white,
                                                       // width: windowsSize.mapViewWidth,
                                                        child: Service(rowcount:4,total:widget.applicationfunctionss.length,applicationfunctionlists:widget.applicationfunctionss ,reset:widget.reset),
                                                      ),
                                                      Container(
                                                        padding: EdgeInsets.only(top: 20),
                                                        color: Colors.white,

                                                      ),
                                                    ],
                                                  ),
                                                )
                                            ),
                                          ),
                                          Container(
                                            padding: EdgeInsets.only(top: 15),
                                            child: Column(
                                              children: <Widget>[
                                                Container(
                                                  width: windowsSize.mapViewWidth,
                                                  //height: windowsSize.mapViewHeight * 0.11,
                                                  // color:Colors.red,
                                                  child: newinformation(newinformationss: widget.newinformations,reset:widget.reset),
                                                ),
                                                Container(
                                                  width: windowsSize.mapViewWidth,
                                                  height: 10,
                                                  // color:Colors.red,
                                                ),

                                               Opacity(
                                                 opacity: 0.3,
                                                 child:  Container(
                                                   padding: EdgeInsets.only(
                                                       bottom: windowsSize.mapViewHeight * 0.81),
                                                   width: windowsSize.mapViewWidth,
                                                   height: 10,
                                                   color: Colors.black12,
                                                   // color:Colors.red,
                                                 ),
                                               ),
                                                Container(
                                                  // color: Colors.red,
                                                  // height: windowsSize.mapViewHeight*0.2,
                                                    width: windowsSize.mapViewWidth,
                                                    //  color: Colors.red,
                                                    child: Row(
                                                      children: <Widget>[
                                                        Container(
                                                          //height: windowsSize.mapViewHeight*0.2,
                                                          // color:Colors.red,
                                                            child: Column(
                                                              children: <Widget>[
                                                                Padding(
                                                                  padding: EdgeInsets.only(
                                                                      top: 20,
                                                                      left: 20,
                                                                      bottom: 20),
                                                                  child: new Image
                                                                      .network( //加载网络图片
                                                                    'http://106.12.180.103/smartDemo/images/ai.png',
                                                                    height: 50.0,
                                                                    width: 50.0,
                                                                    repeat: ImageRepeat.noRepeat, //图片重复方式
                                                                    // fit: BoxFit.fill,
                                                                  ),
                                                                ),
                                                              ],
                                                            )
                                                        ),
                                                        Container(
                                                            padding: EdgeInsets.only(
                                                                bottom: 20),
                                                            // color: Colors.cyanAccent,
                                                            child: Column(
                                                              children: <Widget>[
                                                                Container(
                                                                  padding: EdgeInsets.only(
                                                                      top: 20,
                                                                      left: 10,
                                                                      bottom: 5),
                                                                  // color:Colors.yellow,
                                                                  child: Text("智能客服通道"),
                                                                ),
                                                                Container(
                                                                  padding: EdgeInsets.only(
                                                                      left: 10),
                                                                  // color: Colors.green,
                                                                  child: Text(
                                                                    "(自助服务时间: 7*24小时)",
                                                                    style: TextStyle(
                                                                        fontSize: 10,
                                                                        color: Colors.grey),),
                                                                ),
                                                                Container(
                                                                  padding: EdgeInsets.only(
                                                                      left: 10),
                                                                  // color: Colors.green,
                                                                  child: Text(
                                                                    "(人工服务时间: 8:00-20:00)",
                                                                    style: TextStyle(
                                                                        fontSize: 10,
                                                                        color: Colors.grey),),
                                                                ),
                                                              ],
                                                            )
                                                        ),
                                                        Container(
                                                          padding: EdgeInsets.only(left: 30),
                                                          child: RaisedButton(
                                                            color: Colors.white70,
                                                            highlightColor: Colors.blue[700],
                                                            colorBrightness: Brightness.dark,
                                                            splashColor: Colors.grey,
                                                            child: Text("点击进入",
                                                              style: TextStyle(
                                                                  color: Colors.blue),),
                                                            shape: RoundedRectangleBorder(
                                                              borderRadius: BorderRadius
                                                                  .circular(20.0),
                                                            ),
                                                            onPressed: () =>
                                                            {
                                                              this.navaicateTopage("人工智能")
                                                            },
                                                          ),
                                                        )
                                                      ],
                                                    )
                                                ),

                                                Opacity(
                                                  opacity: 0.3,
                                                  child:  Container(
                                                    padding: EdgeInsets.only(
                                                        bottom: windowsSize.mapViewHeight * 0.81),
                                                    width: windowsSize.mapViewWidth,
                                                    height: 10,
                                                    color: Colors.black12,
                                                    // color:Colors.red,
                                                  ),
                                                ),
                                                Container(
                                                  child: recommendation(recommendationmessages:widget.recommendationmessagess,reset: widget.reset,),
                                                ),

                                                Container(

                                                  height: 20,
                                                )
                                              ],
                                            ),
                                          )
                                        ],
                                      )
                                  ),
                                ),
                              ],
                            ),
                            /* Column(
         children: <Widget>[
             Mypageview() ,
         ],
       ),*/
                          ],
                        ) ,
                      ),
                    ],
                  )
                ],
              ),
            )
          ),



    );
  }
}